﻿
package kliment.display.filters {
	import flash.display.DisplayObject;
	import flash.events.EventDispatcher;
	
	import kliment.display.filters.color.ColorManipulator;
	import kliment.display.filters.color.ColorMatrix;
	import kliment.display.filters.noise.NoiseManipulator;
	
	/**
	* ...
	* @author Kliment
	*/
	public class ImageFilter extends EventDispatcher {
		public static const MAX:Number = 1;
		public static const MIN:Number = -1;
		private var _displayObject:DisplayObject;
		
		private var _colorManipulator:ColorManipulator;
		private var _noiseManipulator:NoiseManipulator;
		
		public function ImageFilter(displayObject:DisplayObject):void {
			_displayObject = displayObject;
			this.addChild(_displayObject);
			
		}
		
		public function get colorManipulator():ColorManipulator {
			if (!_colorManipulator)
				_colorManipulator = new ColorManipulator(_displayObject, this);
			return _colorManipulator;
		}
		
		public function get noiseManipulator():NoiseManipulator {
			if (!_noiseManipulator)
				_noiseManipulator = new NoiseManipulator(_displayObject, this);
			return _noiseManipulator;
		}
		
		public function get colorMatrix():Array {
			if (_colorManipulator)
				return _colorManipulator.colorMatrix;
				
			return ColorMatrix.IDENTITY_MATRIX;
		}
		
		public function get noiseMatrix():Array {
			if (_noiseManipulator)
				return _noiseManipulator.noiseMatrix;
				
			return new Array();
		}
	}
}
